library("plotly")
Loading required package: ggplot2
Want to understand how all the pieces fit together? Read R for Data Science: https://r4ds.had.co.nz/
Registered S3 method overwritten by 'data.table':
method from
print.data.table
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
library("plot3D")
library(tidyverse) # entorno tidy
Registered S3 methods overwritten by 'dbplyr':
method from
print.tbl_lazy
print.tbl_sql
── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.1 ──
✓ tibble 3.1.6 ✓ dplyr 1.0.8
✓ tidyr 1.2.0 ✓ stringr 1.4.0
✓ readr 2.1.2 ✓ forcats 0.5.1
✓ purrr 0.3.4
── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks plotly::filter(), stats::filter()
x dplyr::lag() masks stats::lag()
library(dplyr) # manejo de datos
library(GGally) # scatterplots multiples
Registered S3 method overwritten by 'GGally':
method from
+.gg ggplot2
library(rgl) # para graficos 3D
df = read.csv("chicos.csv", stringsAsFactors = F)
indices = (
! is.na(df$WEIGHT) &
! is.na(df$STATURE) &
! is.na(df$SEX) &
! is.na(df$RACE) &
! is.na(df$AGE.IN.YEARS) &
! is.na(df$AGE.IN.MONTHS) &
df$WEIGHT>0 &
df$STATURE>0 &
df$RACE != 0 &
(df$SEX == 1 | df$SEX==2)
)
dfFiltrados = df[indices,]
```r
unique(df$SEX)
<!-- rnb-source-end -->
<!-- rnb-output-begin eyJkYXRhIjoiWzFdIDIgMVxuIn0= -->
[1] 2 1
<!-- rnb-output-end -->
<!-- rnb-chunk-end -->
<!-- rnb-chunk-begin -->
<!-- rnb-source-begin eyJkYXRhIjoiYGBgclxucmFuZ2UoZGZGaWx0cmFkb3MkQUdFLklOLllFQVJTKVxuYGBgIn0= -->
```r
range(dfFiltrados$AGE.IN.YEARS)
[1] 2015 20054
View(dfFiltrados)
plot(dfFiltrados$WEIGHT/10, dfFiltrados$STATURE/10, xlab = "Peso en KG", ylab = "Altura en CM", col=dfFiltrados$SEX)
plot(dfFiltrados$AGE.IN.MONTHS/12, dfFiltrados$STATURE/10, col=dfFiltrados$SEX, xlab = "Edad (anios)", ylab = "Altura en CM",)
peso = dfFiltrados$WEIGHT/10
edad = dfFiltrados$AGE.IN.MONTHS/12
altura = dfFiltrados$STATURE/10
sexo = dfFiltrados$SEX
colores = c('blue','red')
fig <- plot_ly(x=~altura, y=~edad, z=~peso, marker = list(color = colores[dfFiltrados$SEX], showscale = F) , type="scatter3d", mode="markers", col=sexo, size = 1)
fig <- fig %>% layout(title = 'Peso en funcion de altura y edad'
)
fig
Warning: 'scatter3d' objects don't have these attributes: 'col'
Valid attributes include:
'connectgaps', 'customdata', 'customdatasrc', 'error_x', 'error_y', 'error_z', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meta', 'metasrc', 'mode', 'name', 'opacity', 'projection', 'scene', 'showlegend', 'stream', 'surfaceaxis', 'surfacecolor', 'text', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'visible', 'x', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'ycalendar', 'yhoverformat', 'ysrc', 'z', 'zcalendar', 'zhoverformat', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
Warning: 'scatter3d' objects don't have these attributes: 'col'
Valid attributes include:
'connectgaps', 'customdata', 'customdatasrc', 'error_x', 'error_y', 'error_z', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meta', 'metasrc', 'mode', 'name', 'opacity', 'projection', 'scene', 'showlegend', 'stream', 'surfaceaxis', 'surfacecolor', 'text', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'visible', 'x', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'ycalendar', 'yhoverformat', 'ysrc', 'z', 'zcalendar', 'zhoverformat', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
table(dfFiltrados$RACE)
1 2 3 4 5
3370 426 31 6 51
#Cinco niveles, WHITE = 1, BLACK = 2, ORIENTAL = 3, AMERICAN INDIAN = 4, MIXED = 5.
#Absoluta disparidad de muestreo en cuanto a raza.
table(dfFiltrados$SEX)
1 2
1972 1912
#En cuanto a sexo no
Las personas mas pesadas, desarollan piernas mas anchas para soportar su peso que alguien de su misma altura menos pesada?
Podemos identificar a las personas con enanismo? ademas de menor altura para su edad, que otras variables tienen fundamentalmente distintas?
A que edad pegan “el estiron” los hombres y cuando las mujeres? existe un momento concreto? Ademas de altura, que otras medidas cambian considerablemente? (medida de cintura en mujeres por ej, ensanchamiento de espalda hombres?)